package com.crocodileQ.controller;

import com.crocodileQ.annotation.AutoStatistics;
import com.crocodileQ.common.R;
import com.crocodileQ.constants.SystemConstants;
import com.crocodileQ.domain.VO.BlogUserLoginVO;
import com.crocodileQ.domain.entity.User;
import com.crocodileQ.enums.OperationType;
import com.crocodileQ.service.BlogLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class BlogLoginController {

    @Autowired
    private BlogLoginService blogLoginService;

    /**
     * 用户登录
     * @param user
     * @return
     */
    @AutoStatistics(SystemConstants.LOGIN)
    @PostMapping("/login")
    public R<BlogUserLoginVO> login(@RequestBody User user){


        return blogLoginService.login(user);
    }

    /**
     * 用户退出登录
     * @return
     */
    @PostMapping("/logout")
    public R logout(){

        return blogLoginService.logout();
    }

}
